package com.longge;

public class GetMinimumDifference {

    int ans = Integer.MAX_VALUE;
    int pre = -1;

    public int getMinimumDifference(TreeNode root) {
        dfs(root);
        return ans;
    }

    private void dfs(TreeNode root) {
        if (root == null) return;
        dfs(root.left);
        if (pre == -1) pre = root.val;
        else {
            if (root.val - pre < ans) {
                ans = Math.min(root.val - pre,ans);
            }
            pre = root.val;

        }
        dfs(root.right);
    }
}
